package com.haiyi.software.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.haiyi.software.app.basic.ActivityBasicGiftListView;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

public class ActivityGiftLists extends ActivityBasicGiftListView {

	private Button Button_recharge;

	private TextView textView_myGolds;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		setContentView(R.layout.activity_gift_lists);

		setStr_requestName("giftlist.php");

		getPersonGold();

		initComp();

		userUID = getIntent().getStringExtra("UID");

		super.onCreate(savedInstanceState);
	}

	private void initComp() {
		mPullRefreshListView = (PullToRefreshListView) this
				.findViewById(R.id.pull_refresh_list_gift);

		textView_myGolds = (TextView) this.findViewById(R.id.textView_myGolds);
		Button_recharge = (Button) this.findViewById(R.id.btn_goto_recharge);
		Button_recharge.setOnClickListener(onclick);
	}

	private OnClickListener onclick = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO 自动生成的方法存根
			Intent intent = new Intent();

			intent.setClass(getApplicationContext(), ActivityRecharge.class);

			startActivityForResult(intent, 1);
		}
	};

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO 自动生成的方法存根

		getPersonGold();
	}

	@Override
	protected void sendGiftSuccess(JsonElement jsonReturnSendGif) {
		// TODO 自动生成的方法存根

		getPersonGold();

		Toast.makeText(
				this,
				jsonReturnSendGif.getAsJsonObject().get("desc").getAsString()
						+ jsonReturnSendGif.getAsJsonObject().get("body")
								.getAsString(), Toast.LENGTH_LONG).show();

	}

	@Override
	protected void getMyInfoSuccess(JsonObject myInfBody) {
		// TODO 自动生成的方法存根
		if (myInfBody != null) {
			textView_myGolds.setText(myInfBody.get("gold").getAsString());
		}
	}

	@Override
	protected void requestError() {
		// TODO 自动生成的方法存根

	}
}
